angular.module('fs.waf').run([
  '$rootScope',
  '$templateCache',
  '$locale',
  'storageService',
  'SYS_PARAMS',
  function($rootScope, $templateCache, $locale, storageService, SYS_PARAMS) {
    SYS_PARAMS.CCY_CONFIG = {
      // TODO:this is local data
      USD: 1,
      CNY: 1,
      XX: 2,
      XXX: 3,
      XXXX: 4
    };

    // 配置 sessionStorage , angular-local-storage 可以获取 format 格式化的配置参数
    sessionStorage.setItem(
      'FS_APP.FS_BACKHIS_INFO',
      '[{"pageId":"cda.spa.spaView","fromUrl":"signon","fromParams":{"__originalState":"","__state":"signon"},"toUrl":"cda_spa_spaView","toParams":{"__originalState":"signon","__state":"cda_spa_spaView"}},{"pageId":"waf.home","fromUrl":"cda_spa_spaView","fromParams":{"__originalState":"signon","__state":"cda_spa_spaView"},"toUrl":"waf_home","toParams":{"__originalState":"cda_spa_spaView","__state":"waf_home"}}]'
    );

    // "."和","互换模式
    // sessionStorage.setItem(
    //   'FS_APP.FS_FORMAT_INFO',
    //   '{"decimalSeparator":",","groupSeparator":".","date":"yyyy-MM-dd","defaultFloat":"#0.0##############","defaultMoney":"#,##0.00#","fxRate":"#0.0########","year":"yyyy","longTimestampZ":"yyyy-MM-dd HH:mm:ss.sss Z","defaultPercentage":"#0.0###","integer":"#0","float":"#0.0##############","purchasePercentage":"#0.0###","defaultInteger":"#0","defaultTime":"HH:mm:ss","timestamp":"yyyy-MM-dd HH:mm:ss","timestampZ":"yyyy-MM-dd HH:mm:ss Z","longTimestamp":"yyyy-MM-dd HH:mm:ss.sss","interestRate":"#0.0######","defaultDate":"yyyy-MM-dd","defaultTimestamp":"yyyy-MM-dd HH:mm:ss","orderedDateFormats":["yyyy-MM-dd HH:mm:ss.SSS Z","yyyy-MM-dd HH:mm:ss Z","yyyy-MM-dd HH:mm:ss.SSS","","yyyy-MM-dd","HH:mm:ss.SSS","HH:mm:ss","HH:mm"],"longTime":"HH:mm:ss.sss","month":"yyyy-MM","money":"#,##0.00#","shortTime":"HH:mm:ss","time":"HH:mm:ss","money3":"#,##0.000","money2":"#,##0.00","money1":"#,##0.0","money0":"#,##0"}'
    // );

    sessionStorage.setItem(
      'FS_APP.FS_FORMAT_INFO',
      '{"date":"yyyy-MM-dd","defaultFloat":"#0.0##############","defaultMoney":"#,##0.00#","fxRate":"#0.0########","year":"yyyy","longTimestampZ":"yyyy-MM-dd HH:mm:ss.sss Z","defaultPercentage":"#0.0###","integer":"#0","float":"#0.0##############","purchasePercentage":"#0.0###","defaultInteger":"#0","defaultTime":"HH:mm:ss","timestamp":"yyyy-MM-dd HH:mm:ss","timestampZ":"yyyy-MM-dd HH:mm:ss Z","longTimestamp":"yyyy-MM-dd HH:mm:ss.sss","interestRate":"#0.0######","defaultDate":"yyyy-MM-dd","defaultTimestamp":"yyyy-MM-dd HH:mm:ss","orderedDateFormats":["yyyy-MM-dd HH:mm:ss.SSS Z","yyyy-MM-dd HH:mm:ss Z","yyyy-MM-dd HH:mm:ss.SSS","","yyyy-MM-dd","HH:mm:ss.SSS","HH:mm:ss","HH:mm"],"longTime":"HH:mm:ss.sss","month":"yyyy-MM","money":"#,##0.00#","shortTime":"HH:mm:ss","time":"HH:mm:ss","money3":"#,##0.000","money2":"#,##0.00","money1":"#,##0.0","money0":"#,##0"}'
    );

    sessionStorage.setItem(
      'FS_APP.FS_SITE_INFO',
      '{"siteCode":"FSCSBK","siteName":"FSCSBK","baseCcy":"USD","isFxMultiply":"Y","cutoffTime":"1970-01-01 00:39:00.000","bizDate":"2018-03-28 00:00:00.000","eodDate":"2018-03-28 00:00:00.000","intRateDecimals":3,"fxRateDecimals":3,"glSystem":"GLPT-GLSYSTEM","glpostMgr":"GLPT-MGR"}'
    );

    sessionStorage.setItem(
      'FS_APP.FS_USER_INFO',
      '{"date":"yyyy-MM-dd","defaultFloat":"#0.0##############","defaultMoney":"#,##0.00#","fxRate":"#0.0########","year":"yyyy","longTimestampZ":"yyyy-MM-dd HH:mm:ss.sss Z","defaultPercentage":"#0.0###","integer":"#0","float":"#0.0##############","purchasePercentage":"#0.0###","defaultInteger":"#0","defaultTime":"HH:mm:ss","timestamp":"yyyy-MM-dd HH:mm:ss","timestampZ":"yyyy-MM-dd HH:mm:ss Z","longTimestamp":"yyyy-MM-dd HH:mm:ss.sss","interestRate":"#0.0######","defaultDate":"yyyy-MM-dd","defaultTimestamp":"yyyy-MM-dd HH:mm:ss","orderedDateFormats":["yyyy-MM-dd HH:mm:ss.SSS Z","yyyy-MM-dd HH:mm:ss Z","yyyy-MM-dd HH:mm:ss.SSS","","yyyy-MM-dd","HH:mm:ss.SSS","HH:mm:ss","HH:mm"],"longTime":"HH:mm:ss.sss","month":"yyyy-MM","money":"#,##0.00#","shortTime":"HH:mm:ss","time":"HH:mm:ss","money3":"#,##0.000","money2":"#,##0.00","money1":"#,##0.0","money0":"#,##0"}'
    );

    sessionStorage.setItem('FS_APP._com_pti_waf_PAGE_TOKEN_', 'BB10301262001B3CB42AB0E2F7C1C343');

    var formatInfo = storageService.getFormatInfo();

    if (formatInfo) {
      angular.forEach(formatInfo, function(value, key) {
        if (angular.isString(value)) {
          formatInfo[key] = value.replace('SSS', 'sss');
        }
      });
      storageService.saveFormatInfo(formatInfo);
      angular.extend($locale.DATETIME_FORMATS, formatInfo);
    }

    $rootScope.getBizDate = function() {
      return storageService.getSiteInfo() ? storageService.getSiteInfo().bizDate : new Date();
    };

    $templateCache.put('fs/layout/template/cardTemplate.html', '<div>thi is fsCardTemplate</div>');

    // $rootScope.menus=[
    //   {
    //     actionName: 'demo/fsColor',
    //     displayName: 'fsColor',
    //     subMenuItems:[
    //       {
    //         actionName: 'poi/demo/fsColor',
    //         displayName: 'fsColor'
    //       }
    //     ]
    //   }
    // ]

    $rootScope.menus=[
        {
          actionName: 'demo',
          displayName: 'demo',
          subMenuItems:[
            {
              actionName: 'poi/demo/fsColor',
              displayName: 'fsColor'
            },
            {
              actionName: 'poi/demo/fsImage',
              displayName: 'fsImage'
            },
            {
              actionName: 'poi/demo/fsLabel',
              displayName: 'fsLabel'
            },
            {
              actionName: 'poi/demo/fsLink',
              displayName: 'fsLink'
            },
            {
              actionName: 'poi/demo/fsPassword',
              displayName: 'fsPassword'
            },
            {
              actionName: 'poi/demo/fsText',
              displayName: 'fsText'
            },
            {
              actionName: 'poi/demo/fsTime',
              displayName: 'fsTime'
            },
            {
              actionName: 'poi/demo/fsCheckbox',
              displayName: 'fsCheckbox'
            },
            {
              actionName: 'poi/demo/fsCheckboxGroup',
              displayName: 'fsCheckboxGroup'
            },
            {
              actionName: 'poi/demo/fsRadio',
              displayName: 'fsRadio'
            },
            {
              actionName: 'poi/demo/fsRadioCard',
              displayName: 'fsRadioCard'
            },
            {
              actionName: 'poi/demo/fsCard',
              displayName: 'fsCard'
            },
            {
              actionName: 'poi/demo/fsTextarea',
              displayName: 'fsTextarea'
            },
            {
              actionName: 'poi/demo/fsSelect',
              displayName: 'fsSelect'
            },
            {
              actionName: 'poi/demo/fsDate',
              displayName: 'fsDate'
            },
            {
              actionName: 'poi/demo/fsDateRange',
              displayName: 'fsDateRange'
            },
            {
              actionName: 'poi/demo/fsCalendarDay',
              displayName: 'fsCalendarDay'
            },
            {
              actionName: 'poi/demo/fsNumber',
              displayName: 'fsNumber'
            },
            {
              actionName: 'poi/demo/fsNumberRange',
              displayName: 'fsNumberRange'
            },
            {
              actionName: 'poi/demo/fsMoney',
              displayName: 'fsMoney'
            },
            {
              actionName: 'poi/demo/fsMoneyRange',
              displayName: 'fsMoneyRange'
            },
            {
              actionName: 'poi/demo/fsPercentage',
              displayName: 'fsPercentage'
            },
            {
              actionName: 'poi/demo/fsPercentageRange',
              displayName: 'fsPercentageRange'
            },
            {
              actionName: 'poi/demo/fsTypeahead',
              displayName: 'fsTypeahead'
            },
            {
              actionName: 'poi/demo/fsSensitive',
              displayName: 'fsSensitive'
            },
            {
              actionName: 'poi/demo/fsCustomerSelect',
              displayName: 'fsCustomerSelect'
            },
            {
              actionName: 'poi/demo/fsMultipleSelect',
              displayName: 'fsMultipleSelect'
            },
            {
              actionName: 'poi/demo/fsLookupText',
              displayName: 'fsLookupText'
            },
            {
              actionName: 'poi/demo/fsLookupMultiple',
              displayName: 'fsLookupMultiple'
            },
            {
              actionName: 'poi/demo/fsFileUpload',
              displayName: 'fsFileUpload'
            },
            {
              actionName: 'poi/demo/fsButtons',
              displayName: 'fsButtons'
            },
            {
              actionName: 'poi/demo/fsButton',
              displayName: 'fsButton'
            }
          ]
        }
    ]
  }
]);
